package com.dxb.uc.controller;

import com.alibaba.nacos.api.exception.NacosException;
import com.dxb.uc.NacosService;
import com.dxb.uc.config.DataShareConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("ds")
public class DynamicDsController {
    @Autowired
    private NacosService nacosService;

   public static String dataId = "shareconfig3.yml";
   public static String group = "SHARE3_GROUP";

    @Autowired
    private DataShareConfig config;

    @GetMapping("config")
    public Object config() {
        return config.getDataList();
    }

    /**
     * Description：修改配置 <br>
     * date：2022/3/25/025 8:44 <br>
     *
     * @param name <br>
     * @return <br>
     */
    @GetMapping("add")
    public Object add(String name) throws NacosException {
        return nacosService.add(dataId, group, name);
    }

    /**
     * Description：获取nacos配置 <br>
     * date：2022/3/25/025 8:43 <br>
     *
     * @return <br>
     */
    @GetMapping("get")
    public Object get() throws NacosException {
        return nacosService.get(dataId, group);
    }


}
